package com.joey.cloud.dic.business.controller;


import com.baomidou.mybatisplus.extension.service.IService;
import com.joey.cloud.communal.utils.BaseController;
import com.joey.cloud.communal.utils.ResponseUtil;
import com.joey.cloud.dic.business.entity.SysDicLeft;
import com.joey.cloud.dic.business.entity.SysDicRight;
import com.joey.cloud.dic.business.service.ISysDicRightService;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 * 数据字典右表  前端控制器
 * </p>
 *
 * @author Joey
 * @since 2021-03-21
 */
@Api(tags = "数据字典右表")
@Slf4j
@RestController
@RequestMapping("/business/dicRight")
public class SysDicRightController extends BaseController<SysDicRight> {
    @Resource
    ISysDicRightService sysDicRightService;

    @Override
    public IService<SysDicRight> getService() {
        return sysDicRightService;
    }

    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "获取字典值文本")
    @GetMapping("/queryTextByKey")
    @ApiImplicitParams({
            @ApiImplicitParam(name="leftKey",value="左表标识", paramType = "query",required = true),
            @ApiImplicitParam(name="dicKeys",value="字典值标识", paramType = "query",required = true)
    })
    public ResponseUtil queryTextByKey(String leftKey,String dicKeys){
        try {
            String dicText = sysDicRightService.queryTextByKey(leftKey,dicKeys);
            return ResponseUtil.success(dicText);
        }catch (Exception e){
            log.error("获取字典值文本出错",e);
            return ResponseUtil.error();
        }
    }
}

